<template>
    <a-spin :spinning="spin">
        <a-row :gutter="20">
            <a-col :md="12" :span="24">
                <br/>
                <a-card style="color: black; font-weight: bold">
                    用户名：{{user.name}}
                    <br/>
                    邮箱：{{user.email}}
                    <br/>
                    权限：
                    <span v-if="user.type==-1">
                        超级管理员<a-divider type="vertical"/>
                        <a-tag color="orange">
                            <strong style="font-size: small">
                                SuperAdmin
                            </strong>
                        </a-tag>
                    </span>
                    <span v-if="user.type==0">
                        管理员<a-divider type="vertical"/>
                        <a-tag color="orange">
                            <strong style="font-size: small">
                                Admin
                            </strong>
                        </a-tag>
                    </span>
                    <span v-if="user.type==1">学生Student</span>
                    <span v-if="user.type==2">普通用户Guest</span>
                    <span v-if="user.type != 2">
                        <br/>
                        班级：{{user.clazz}}
                        <br/>
                        届数：{{user.sess}}
                    </span>
                </a-card>
            </a-col>
            <a-col :md="12" :span="24">
                <br/>
                <a-card>
                    <a-row :gutter="20">
                        <a-col :span="12" @click="$router.push('/followList')" style="cursor: pointer">
                            <a-statistic title="关注" :value="user.follow.length"/>
                        </a-col>
                        <a-col :span="12" @click="$router.push('/fansList')" style="cursor: pointer">
                            <a-statistic title="粉丝" :value="user.fans.length"/>
                        </a-col>
                    </a-row>
                </a-card>
            </a-col>
        </a-row>

        <a-row :gutter="20">
            <a-col :md="12" :span="24">
                <br/>
                <a-card>
                    <a-row :gutter="20">
                        <a-col :span="12">
                            <a-statistic title="文章数" :value="atcNum" />
                        </a-col>
                        <a-col :span="12">
                            <a-statistic title="评论数" :value="cmtNum" />
                        </a-col>
                    </a-row>
                </a-card>
            </a-col>
            <a-col :md="12" :span="24">
                <br/>
                <a-card>
                    <a-row :gutter="20">
                        <a-col :span="8">
                            <a-statistic title="总阅读量" :value="info.views" />
                        </a-col>
                        <a-col :span="8">
                            <a-statistic title="总点赞量" :value="info.likes" />
                        </a-col>
                        <a-col :span="8">
                            <a-statistic title="总点亮量" :value="info.lights" />
                        </a-col>
                    </a-row>
                </a-card>
            </a-col>
        </a-row>
        <br/>
        <br/>
    </a-spin>
</template>

<script>
    export default {
        name: "Info",
        data(){
            return{
                spin: true,
                user: '',

                atcNum: 0,
                cmtNum: 0,
                info: [],
            }
        },
        created() {
            this.getData();
        },
        mounted() {
            this.spin = false;
        },
        methods:{
            getData(){
                const t = this;
                axios.get('/user/getUser').then(function (resp) {
                    t.user = resp.data;
                })
                axios.get('/atc/getMyInfo').then(function (resp) {
                    t.info = resp.data;
                })
                axios.get('/atc/getMyAtc').then(function (resp) {
                    t.atcNum = resp.data.length;
                })
                axios.get('/cmt/getMyCmt').then(function (resp) {
                    t.cmtNum = resp.data.length;
                })
            }
        }
    }
</script>

<style scoped>

</style>